package studiodiva.portfolio.client.view.particleengine;

class Vector {
  private double tx, tz;
  private double x;
  private double y;
  private double z;
  private double cosRY, sinRY;

  Vector(double x, double y, double z) {
    reset(x, y, z);
  }

  public void addY(int gravity) {
    y += gravity;
  }

  public double getX() {
    return x;
  }

  public double getY() {
    return y;
  }

  public double getZ() {
    return z;
  }

  public void multiplyEq(double s) {
    x *= s;
    y *= s;
    z *= s;
  }

  public void plusEq(Vector vector) {
    x += vector.x;
    y += vector.y;
    z += vector.z;
  }

  public void reset(double x, double y, double z) {
    this.x = x;
    this.y = y;
    this.z = z;
  }

  public void rotateY(double angle) {
    tx = x;
    tz = z;
    cosRY = Math.cos(angle);
    sinRY = Math.sin(angle);
    x = tx * cosRY + tz * sinRY;
    z = tx * -sinRY + tz * cosRY;
  }
}